home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / sun3.md / start.s < prev    next >
Encoding:
Text File  |  1989-06-18  |  2.0 KB  |  75 lines

  1. |* start.s
  2. |*
  3. |*    Initial instructions executed by a boot program loaded by the PROM.
  4. |*    This is derived from 
  5. |*    "@(#)srt0.s    4.15 83/10/12    Copyr 1983 Sun Micro";
  6. |*    The first thing done here is to relocate the boot program if
  7. |*    the boot PROM hasn't loaded the program into the expected place.
  8. |*    After that the stack is set up, BSS area is zero filled, and
  9. |*    then the code jumps to main().  The entry point to transfer to
  10. |*    another program is also defined here.
  11. |*
  12. #ifdef notdef
  13. .data
  14. .asciz "$Header: /sprite/src/boot/scsiDiskBoot/RCS/start.s,v 1.5 89/01/06 08:10:09 brent Exp $ SPRITE (Berkeley)"
  15. .even
  16. #endif not lint
  17. .text
  18.  
  19. #include "machConst.h"
  20.  
  21.     .globl    _etext
  22.     .globl    _edata
  23.     .globl    _end
  24.     .globl    _main
  25.     .globl    _Boot_Exit
  26.     .globl    _Boot_Transfer
  27.  
  28.     .globl    start
  29. start:
  30. #ifdef notdef
  31.     movw    #MACH_SR_HIGHPRIO,sr    | lock out interrupts, just in case
  32. #endif
  33. leax:    lea    pc@(start-(leax+2)),a0    | True current location of "start"
  34.     lea    start:l,a1        | Desired      location of "start"
  35.     cmpl    a0,a1
  36.     jeq    begin            | If the same, just go do it.
  37.     movl    #_edata,d0        | Desired end of program
  38.     subl    a1,d0            | Calculate length, round up.
  39.     lsrl    #2,d0
  40. movc:    movl    a0@+,a1@+        | Move it where it belongs.
  41.     dbra    d0,movc
  42.     jmp    begin:l            | Force non-PCrel jump
  43.  
  44. begin:
  45.     movl    sp,start-4:l        | Save old stack pointer value
  46.     lea    start-4:l,sp        | Set up new stack below load point
  47.     movl    #_edata,a0        | Zero fill BSS area (and _endData)
  48. clr:
  49.     clrl    a0@+
  50.     cmpl    #_end,a0
  51.     ble    clr
  52. |
  53. | Argc and argv are set to zeros here and the boot main program knows
  54. | to get arguments from the monitor vector.
  55. |
  56.     clrl    sp@-            | argv = 0 for now.
  57.     clrl    sp@-            | argc = 0 for now.
  58.     jsr    _main
  59.     addqw    #8,sp
  60.     jsr    _Exit            | after main() returns, call Exit().
  61. | Just fall thru into _Boot_Exit if exit() ever returns.
  62.  
  63. _Boot_Exit:
  64.     movl    start-4:l,sp        | Restore caller's stack pointer
  65.     rts                | Return to caller (PROM probably)
  66.  
  67. | Boot_Transfer --
  68. | Transfer control to a new program, no arguments are set up.
  69.  
  70. _Boot_Transfer:
  71.     movl    sp@(4),a0        | Address to call
  72.     movl    a0,sp            | Set the stack below the load point
  73.     jra    a0@            | Jump to callee using new stack
  74.  
  75.